$(function() {
	var message = {
		open: function(msg, title) {
			if ($('#msg')[0] == null) {
				$('body').append('<div id="msg" title="' + title + '">' + msg + '</div>');
				$("#msg").dialog({
					bgiframe: true,
					closeOnEscape: true,
					modal: true,
					buttons: {
						OK: function() {
							$(this).dialog('close');
						}
					}
				});
			} else {
				this.show(msg);
			}
		},
		show: function(msg) {
			$('#msg').html(msg).dialog('open');
		}
	}
	$("#panel").tabs();
	$("#login > form").submit(
		function() {
			var user_account = $('#user_account').val();
			var user_password = $('#user_password').val();
			var error = false;
			if ($.trim(user_account) != '' && $.trim(user_password) != '') {
				$('#login > form > input[type="submit"]').attr('disabled', true);
				$.ajax({
					url: 'application.php?app=member&sub_app=user&method=CheckUserLogin&data_type=json',
					type: 'POST',
					data: {
						user_account: user_account,
						user_password: user_password
					},
					dataType: 'json',
					success: function(result) {
						if (true == result.UserLogin) {
							window.location.href = 'platform.php';
						} else {
							error_msg = '<div class="error_msg">' + result.UserLoginErrorMsg + '</div>';
							message.open(error_msg, 'Login Error');
							return false;
						}
					}
				});
			}
			return false;
		}
	);
});